-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pytests: Add conftest.py and other tests #73
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, please add comments to your code, explaining what is tested.
pytest/test_raw_image_option.py
Outdated
in_yaml = os.path.join(CONFIG_DIR, "raw-image.yaml") | ||
|
||
basename = os.path.basename(in_yaml.rsplit(".", 1)[0]) | ||
out_ovf = os.path.join(WORK_DIR, f"{basename}.ovf") | ||
|
||
process = subprocess.run([OVA_COMPOSE, "-i", in_yaml, "-o", out_ovf, "--vmdk-convert", VMDK_CONVERT], cwd=WORK_DIR) | ||
assert process.returncode == 0 | ||
|
||
with open(in_yaml) as f: | ||
yaml_loader = yaml.SafeLoader | ||
yaml_loader.app_params = {} | ||
yaml.add_constructor("!param", yaml_param, Loader=yaml_loader) | ||
config = yaml.load(f, Loader=yaml_loader) | ||
|
||
with open(out_ovf) as f: | ||
ovf = xmltodict.parse(f.read()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is also in test_all_configs.py
, so I think this should be in a common file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pytest/test_raw_image_option.py
Outdated
with open(out_ovf) as f: | ||
ovf = xmltodict.parse(f.read()) | ||
|
||
test_all_configs.test_envelope_configs((config, ovf)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like invoking a function in another test_*.py
file - so I think test_envelope_configs
shopuld be in a separate file, that is imported by both test_all_configs.py
and test_raw_image_option.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
341d2b8
to
b1cd8d0
Compare
b1cd8d0
to
5007250
Compare
conftest.py contain common fixtures to setup and teardown. We use them wherever feasible Added Configurations and Hardware section tests in tests_all_configs. It tests the keys present under those section in our config file. pytest/test_raw_image_option.py checks .img if provided instead of vmdk should still work. After that it matches values for the same in ovf and our yaml.
conftest.py contain common fixtures to setup and teardown.
We use them wherever feasible
Added Configurations and Hardware section tests in tests_all_configs.
It tests the keys present under those section in our config file.
pytest/test_raw_image_option.py checks .img if provided instead
of vmdk should still work.
After that it matches values for the same in ovf and our yaml.